<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *公告管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';

if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid']);
	$return['list']=pdo_getall('jy_weishop_goods_brand',$params,array('id','title','image'));
	foreach($return['list'] as $k=>&$v){
		$goodsid=pdo_getall('jy_weishop_goods',array('brandid'=>$v['id'],'uniacid'=>$_SESSION['uniacid']),array('id'),'id');
		if($goodsid){
			$goodsid=array_keys($goodsid);
		}else{
			$goodsid=-1;
		}
		$v['total']=pdo_getsum('jy_weishop_order_goods',array('ispay'=>1,'goodsid'=>$goodsid,'uniacid'=>$_SESSION['uniacid']),'total');
		$v['totalprice']=pdo_getsum('jy_weishop_order_goods',array('ispay'=>1,'goodsid'=>$goodsid,'uniacid'=>$_SESSION['uniacid']),'total_price');
	}
	paixu($return['list'],'total','desc');
	foreach($return['list'] as $k=>&$v){
		$v['rank']=$k+1;
	}
	$htmls=array(
		'type'=>'list',
		'list'=>array('data'=>'list','delall'=>false,'del_one'=>false,'edit'=>false,'list'=>array(
			array('name'=>'rank','title'=>'排行','type'=>'string'),
			array('name'=>'title','title'=>'品牌名称','type'=>'string'),
			array('name'=>'image','title'=>'品牌图片','type'=>'image'),			
			array('name'=>'total','title'=>'总销售量','type'=>'string'),
			array('name'=>'totalprice','title'=>'总销售额','type'=>'string'),
		),'action'=>array(
			array('type'=>'href','action'=>'jy_weishop/statistics.brand_one/','title'=>'查看详细数据'),
		)),
	);
	$return['htmls']=$htmls;
	exi($return);
}
